package demoTest;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

/**
 * 在return之前，先执行finally中的代码
 */
public class FinallyDemo {

    public static void main(String[] args) {

        System.out.println(get());



        List<Data> list = new ArrayList<>();
        list.add(new Data("wen",23));
        list.add(new Data("mable",23));
        list.add(new Data("zao",1));

        Data[] datas = {new Data("wen",23),new Data("mable",23)};

        Arrays.sort(datas, Comparator.comparingInt(Data::getAge));


        list.forEach(System.out::println);
    }

    public static String get(){
        try {
            return "hello";
        } finally {
            System.out.println("world");
        }
    }
}



class Data{

    private String name;

    private int age;

    public Data(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
